package com.tckdq.tcc.service.impl;

import com.tckdq.tcc.domain.MessageStation;
import com.tckdq.tcc.dto.StationMessage2MQDto;
import com.tckdq.tcc.mapper.MessageStationMapper;
import com.tckdq.tcc.service.IMessageStationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-08-15
 */
@Service
public class MessageStationServiceImpl extends ServiceImpl<MessageStationMapper, MessageStation> implements IMessageStationService {


    @Override
    public void saveStationMessage(StationMessage2MQDto message2MQDto) {
        MessageStation messageStation = new MessageStation();
        Date date = new Date();
        message2MQDto.getUserIds().forEach(userId ->{
            messageStation.setContent(message2MQDto.getContent());
            messageStation.setIsread(0);
            messageStation.setSendTime(date);
            messageStation.setTitle(message2MQDto.getTitle());
            messageStation.setType(message2MQDto.getType());
            messageStation.getUserId(userId);
            insert(messageStation);
        });
    }
}
